package com.heu.blood.dict.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import com.heu.blood.common.aop.ControllerLogAnnotation;
import com.heu.blood.dict.vo.BloodProductVo;
import com.heu.blood.dict.vo.DepartmentDictVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.heu.blood.dict.entity.DictBloodProductEntity;
import com.heu.blood.dict.service.DictBloodProductService;
import com.heu.blood.common.utils.PageUtils;
import com.heu.blood.common.utils.R;



/**
 * 
 *
 * @author lhh
 * @email lhh1612325771@163.com
 * @date 2024-06-27 10:58:54
 */
@RestController
@RequestMapping("blood/dictbloodproduct")
public class DictBloodProductController {
    @Autowired
    private DictBloodProductService dictBloodProductService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @ControllerLogAnnotation(module = "字典血液品信息", operate = "分页查询血液品列表")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = dictBloodProductService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 查询树形控件
     */
    @RequestMapping("/tree")
    @ControllerLogAnnotation(module = "字典血液品信息", operate = "查询树形控件")
    public R getTreeRes(@RequestParam Map<String, Object> params){
        List<BloodProductVo> res = dictBloodProductService.getTreeRes();
        return R.ok().put("data",res);
    }
    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @ControllerLogAnnotation(module = "字典血液品信息", operate = "根据id查询血液品信息")
    public R info(@PathVariable("id") Long id){
		DictBloodProductEntity dictBloodProduct = dictBloodProductService.getById(id);

        return R.ok().put("dictBloodProduct", dictBloodProduct);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @ControllerLogAnnotation(module = "字典血液品信息", operate = "保存血液品信息")
    public R save(@RequestBody DictBloodProductEntity dictBloodProduct){
		dictBloodProductService.save(dictBloodProduct);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @ControllerLogAnnotation(module = "字典血液品信息", operate = "修改血液品信息")
    public R update(@RequestBody DictBloodProductEntity dictBloodProduct){
		dictBloodProductService.updateById(dictBloodProduct);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @ControllerLogAnnotation(module = "字典血液品信息", operate = "删除血液品信息")
    public R delete(@RequestBody Long[] ids){
		dictBloodProductService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
